package com.maybach.core.flow.handler;

import com.maybach.workflow.common.AbstractHanlder;
import com.maybach.workflow.common.api.IFlowHandler;
import com.maybach.workflow.common.api.WorkFlowContext;
import com.maybach.workflow.common.api.enums.FlowStateEnum;
import com.maybach.workflow.common.api.enums.WFContextKeyEnum;
import com.maybach.workflow.common.model.FlowApplyDO;
import com.maybach.workflow.core.manager.FlowApplyManager;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * Created by houenxun on 16/1/28.
 */
public abstract  class FinishSimpleFlow extends AbstractHanlder implements IFlowHandler {
    @Autowired
    protected FlowApplyManager flowApplyManager;
    @Override
    public void handle(WorkFlowContext context) {
        FlowApplyDO apply = (FlowApplyDO)context.getBizData().get(WFContextKeyEnum.flowApplyDO.name());

        FlowApplyDO flowApplyDO = new FlowApplyDO();
        flowApplyDO.setId(apply.getId());
        flowApplyDO.setState(FlowStateEnum.end.getStatus());
        flowApplyManager.updateByPrimaryKeySelective(flowApplyDO);
    }
}
